package lesson3.slides.io;

import java.io.*;

public class CopyTextFile {

    public static void main(String[] args) {
        int count = 0;
        try {
            FileReader in = new FileReader("filesource.txt");
            FileWriter out = new FileWriter("filesink.txt");
            int c;
            while ((c = in.read()) != -1) {
                count++;
                out.write(c);
            }
            in.close();
            out.close();
        } catch (IOException e) {
            System.err.println(e.getMessage());
        }
        System.out.println("Copied " + count + " characters");
    }
}
